package com.tgky.ybzb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tgky.ybzb.common.PageParam;
import com.tgky.ybzb.utils.MPUtil;
import com.tgky.ybzb.entity.Gcxq;
import com.tgky.ybzb.mapper.GcxqMapper;
import com.tgky.ybzb.service.IGcxqService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * 观察需求表 服务实现类
 *
 * @author XYP
 * @since 2024-07-22
 */
@Service
public class GcxqServiceImpl extends ServiceImpl<GcxqMapper, Gcxq> implements IGcxqService {

    /**
     * 通过实体类获取QueryWrapper
     * @param pageParam 分页参数
     * @param gcxq 实体信息
     * @return
     */
    @Override
    public QueryWrapper<Gcxq> getQueryWrapper(PageParam pageParam, Gcxq gcxq){
        QueryWrapper<Gcxq> queryWrapper = MPUtil.getQueryWrapper(pageParam);

        if(gcxq == null){
            return queryWrapper;
        }

        //主键
        if(gcxq.getXqid() != null){
            queryWrapper.lambda()
                    .eq(Gcxq::getXqid, gcxq.getXqid());
            return queryWrapper;
        }

        //TODO 此处可以根据各字段查询需求修改查询条件，eq、like、ge、gt、le、lt、ne...等等等
        queryWrapper.lambda()
                .eq(gcxq.getRwlx() != null, Gcxq::getRwlx, gcxq.getRwlx())
                .eq(gcxq.getMbxt() != null, Gcxq::getMbxt, gcxq.getMbxt())
                .eq(gcxq.getQxtj() != null, Gcxq::getQxtj, gcxq.getQxtj())
                .eq(gcxq.getGjys() != null, Gcxq::getGjys, gcxq.getGjys())
                .eq(gcxq.getSfdcjm() != null, Gcxq::getSfdcjm, gcxq.getSfdcjm())
                .eq(gcxq.getSfhzmb() != null, Gcxq::getSfhzmb, gcxq.getSfhzmb())
                .eq(gcxq.getZhlx() != null, Gcxq::getZhlx, gcxq.getZhlx())
                .eq(gcxq.getGzms() != null, Gcxq::getGzms, gcxq.getGzms())
                .eq(gcxq.getFbl() != null, Gcxq::getFbl, gcxq.getFbl())
                .eq(gcxq.getYxj() != null, Gcxq::getYxj, gcxq.getYxj());
        return queryWrapper;
    }
}
